#ifndef MTPINTERFACE_H
#define MTPINTERFACE_H

#include <QObject>
#include <QProcess>
#include "common.h"
#include "syncstatusdialog.h"
#include "xmlinterface.h"
#include "localinterface.h"

class MTPInterface : public QObject
{
    Q_OBJECT
public:
    explicit MTPInterface(XMLInterface *xmlInt, LocalInterface *locInt, QObject *parent = 0);

    void copyXMLFromDevice();
    void copyAllDataFromDevice(QString folderPath);
    void deleteProp(QString pName, bool update = false);
    void deleteFile(QString pName, QString fName, bool update = false);
    void renameProp(QString pNameOld, QString pNameNew, bool update = false);

private:
    enum PREFIX { COMMAND, FILE_AUD, FILE_VID, FILE_PIC, FILE_XML, PROP_NAME, FILE_TXT, DELETE_FILE, DELETE_PROP, RENAME_PROP, COPY_ALL_DATA };
    enum COMMAND_TYPE { COPY, END_COPY, END_PROP, QUIT, DEV_DISCONNECT, DEV_CONNECT, TMP_XML_PATH, FILE_EXISTS, AUDIO_SCRIPT, COPY_ALL_COMPLETE };
    QProcess *mtpCopyProc;
    XMLInterface *xml;
    LocalInterface *loc;

    QByteArray sendFile(QString path, bool localPath, PREFIX ft, QString propName = "");

signals:
    void logMessage(QString message, MESSAGE_TYPE mtype);
    void copyInProgress(bool copy);
    void deviceConnect(bool connect);
    void updateDevice();
    void restartMTP();

public slots:
    void pushData();
    void closeMtpCopy();
    void mtpProcError(QProcess::ProcessError error);
    void setPropAudioScriptFromDevice(PropData *prop);
    void restartMTPProc();

private slots:
    void mtpCopyProcOutput();
};

#endif // MTPINTERFACE_H
